package com.ywjt.platformbusiness.store.adapter;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ywjt.platformbusiness.EventBusBean;
import com.ywjt.platformbusiness.R;
import com.ywjt.platformbusiness.store.model.WeekThisYear;

import org.greenrobot.eventbus.EventBus;

import java.util.List;

public class WeekThisYearPAdapter extends BaseQuickAdapter<WeekThisYear.ResultDTO, BaseViewHolder> {

    public WeekThisYearPAdapter(@Nullable List<WeekThisYear.ResultDTO> data) {
        super(R.layout.item_week_thisyearp, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, WeekThisYear.ResultDTO item) {
        helper.setText(R.id.tvYearMonth,item.getKey());
        RecyclerView rcCommon=helper.getView(R.id.rcCommon);

        WeekThisYearCAdapter adapter=new WeekThisYearCAdapter(item.getValues());
        GridLayoutManager manager=new GridLayoutManager(mContext,4,RecyclerView.VERTICAL,false);
        rcCommon.setLayoutManager(manager);
        rcCommon.setAdapter(adapter);
        adapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                //点击了
                EventBusBean busBean=new EventBusBean();
                busBean.setCode(101);
                busBean.setMsg(item.getKey()+"-"+item.getValues().get(position).getValue());
                EventBus.getDefault().post(busBean);
            }
        });

    }
}
